function createdb() {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
//    var db = openDatabaseSync("test", "1.0", "test", 5000000);
    db.transaction(
        function(tx) {
            tx.executeSql('CREATE TABLE IF NOT EXISTS Setting(id INTEGER primary key'
                          + ', setting_gps_status BOOLEAN, setting_gps_follow_me BOOLEAN'
                          + ', setting_gps_update_interval INTEGER, setting_gps_follow_interval INTEGER'
                          + ', setting_gps_last_lat TEXT, setting_gps_last_lon TEXT'
                          + ', setting_sogou_last_lat TEXT, setting_sogou_last_lon TEXT'
                          + ', setting_sogou_map_level INTEGER'
                          + ', notification_show_time INTEGER, setting_style TEXT'
                          + ', bus_start_text TEXT, bus_start_lonlat TEXT'
                          + ', bus_end_text TEXT, bus_end_lonlat TEXT'
                          + ', bus_avoid TEXT, bus_tactic TEXT'
                          + ', bus_maxResultCount TEXT, bus_maxDist TEXT'
                          + ', search_maxResultCount INTEGER'
                          + ', drive_tactic TEXT'
                          + ')');
            var rs = tx.executeSql('SELECT * FROM Setting');
            if(rs.rows.length==0)
            {
                tx.executeSql('INSERT INTO Setting VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
                              , [ 1, true, false, 10, 10, "", "", "12957062,4827187", "", 10, 5000, "", "", "", "", "", "", "", "", "", 20, "" ]);
            }
        }
    )
}

function set_setting_gps_status(setting_gps_status) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_gps_status=?',[setting_gps_status]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_gps_status=? WHERE id=1', [ setting_gps_status ]);
            }
        }
    )
}

function set_setting_gps_follow_me(setting_gps_follow_me) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_gps_follow_me=?',[setting_gps_follow_me]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_gps_follow_me=? WHERE id=1', [ setting_gps_follow_me ]);
            }
        }
    )
}

function set_setting_gps_update_interval(setting_gps_update_interval) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_gps_update_interval=?',[setting_gps_update_interval]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_gps_update_interval=? WHERE id=1', [ setting_gps_update_interval ]);
            }
        }
    )
}

function set_setting_gps_follow_interval(setting_gps_follow_interval) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_gps_follow_interval=?',[setting_gps_follow_interval]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_gps_follow_interval=? WHERE id=1', [ setting_gps_follow_interval ]);
            }
        }
    )
}

function set_setting_gps_last_lat(setting_gps_last_lat) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_gps_last_lat=?',[setting_gps_last_lat]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_gps_last_lat=? WHERE id=1', [ setting_gps_last_lat ]);
            }
        }
    )
}

function set_setting_gps_last_lon(setting_gps_last_lon) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_gps_last_lon=?',[setting_gps_last_lon]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_gps_last_lon=? WHERE id=1', [ setting_gps_last_lon ]);
            }
        }
    )
}

function set_setting_sogou_last_lat(setting_sogou_last_lat) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_sogou_last_lat=?',[setting_sogou_last_lat]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_sogou_last_lat=? WHERE id=1', [ setting_sogou_last_lat ]);
            }
        }
    )
}

function set_setting_sogou_last_lon(setting_sogou_last_lon) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_sogou_last_lon=?',[setting_sogou_last_lon]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_sogou_last_lon=? WHERE id=1', [ setting_sogou_last_lon ]);
            }
        }
    )
}

function set_setting_sogou_map_level(setting_sogou_map_level) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_sogou_map_level=?',[setting_sogou_map_level]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_sogou_map_level=? WHERE id=1', [ setting_sogou_map_level ]);
            }
        }
    )
}

function set_setting_style(setting_style) {
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE setting_style=?',[setting_style]);
            if(rs.rows.length==0)
            {
                tx.executeSql('UPDATE Setting SET setting_style=? WHERE id=1', [ setting_style ]);
            }
        }
    )
}



function get_setting_gps_status() {
    var setting_gps_status = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_gps_status = rs.rows.item(0).setting_gps_status;
            }
        }
    )
    return setting_gps_status;
}

function get_setting_gps_follow_me() {
    var setting_gps_follow_me = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_gps_follow_me = rs.rows.item(0).setting_gps_follow_me;
            }
        }
    )
    return setting_gps_follow_me;
}

function get_setting_gps_update_interval() {
    var setting_gps_update_interval = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_gps_update_interval = rs.rows.item(0).setting_gps_update_interval;
            }
        }
    )
    return setting_gps_update_interval;
}

function get_setting_gps_follow_interval() {
    var setting_gps_follow_interval = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_gps_follow_interval = rs.rows.item(0).setting_gps_follow_interval;
            }
        }
    )
    return setting_gps_follow_interval;
}

function get_setting_gps_last_lat() {
    var setting_gps_last_lat = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_gps_last_lat = rs.rows.item(0).setting_gps_last_lat;
            }
        }
    )
    return setting_gps_last_lat;
}

function get_setting_gps_last_lon() {
    var setting_gps_last_lon = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_gps_last_lon = rs.rows.item(0).setting_gps_last_lon;
            }
        }
    )
    return setting_gps_last_lon;
}

function get_setting_sogou_last_lat() {
    var setting_sogou_last_lat = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_sogou_last_lat = rs.rows.item(0).setting_sogou_last_lat;
            }
        }
    )
    return setting_sogou_last_lat;
}

function get_setting_sogou_last_lon() {
    var setting_sogou_last_lon = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_sogou_last_lon = rs.rows.item(0).setting_sogou_last_lon;
            }
        }
    )
    return setting_sogou_last_lon;
}

function get_setting_sogou_map_level() {
    var setting_sogou_map_level = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_sogou_map_level = rs.rows.item(0).setting_sogou_map_level;
            }
        }
    )
    return setting_sogou_map_level;
}

function get_setting_style() {
    var setting_style = "";
    var db = openDatabaseSync("Setting", "1.0", "MapSetting", 5000000);
    db.transaction(
        function(tx) {
            var rs = tx.executeSql('SELECT * FROM Setting WHERE id=1');
            if(rs.rows.length>0)
            {
                setting_style = rs.rows.item(0).setting_style;
            }
        }
    )
    return setting_style;
}


